<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增疾病管理')" />
    <th:block th:include="include :: summernote-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-disease-add" style="padding: 20px">
            <div class="form-group">
                <div class="col-sm-6">
                    <label class="col-sm-2 control-label">疾病名称：</label>
                    <div class="col-sm-10">
                        <input name="name" class="form-control" type="text">
                    </div>
                </div>
                <div class="col-sm-6">
                    <label class="col-sm-2 control-label">疾病英文名称：</label>
                    <div class="col-sm-10">
                        <input name="englishName" class="form-control" type="text">
                    </div>
                </div>
            </div>

            <div class="form-group">
                <div class="col-sm-6">
                    <label class="col-sm-2 control-label">描述：</label>
                    <div class="col-sm-10">
                        <input name="description" class="form-control" type="text">
                    </div>
                </div>
                <div class="col-sm-6">
                    <label class="col-sm-2 control-label">关键词：</label>
                    <div class="col-sm-10">
                        <input name="keyword" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-1 control-label">疾病介绍：</label>
                <div class="col-sm-11">
                    <input type="hidden" class="form-control" name="content">
                    <div class="summernote" id="content"></div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-1 control-label">排序：</label>
                <div class="col-sm-11">
                    <input name="sort" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-1 control-label">温馨提示：</label>
                <div class="col-sm-11">
                    <textarea name="warmPrompt" class="form-control"></textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-1 control-label">参考资料：</label>
                <div class="col-sm-11">
                    <textarea name="referenceMaterial" class="form-control"></textarea>
                </div>
            </div>
            <div class="">
                <input type="hidden" class="form-control" value="02" name="type">
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: summernote-js" />
    <script th:inline="javascript">
        var prefix = ctx + "ydz/japanDisease"
        $("#form-disease-add").validate({
            focusCleanup: true
        });

        //初始化加载
        $(document).ready(function () {
            parent.$('body').find('.layui-layer-max:not(.layui-layer-maxmin)').click()
        })

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-disease-add').serialize());
            }
        }

        $(function() {
            $('.summernote').summernote({
                lang: 'zh-CN',
                dialogsInBody: true,
                callbacks: {
                    onChange: function(contents, $edittable) {
                        $("input[name='" + this.id + "']").val(contents);
                    },
                    onImageUpload: function(files) {
                        var obj = this;
                    	var data = new FormData();
                    	data.append("file", files[0]);
                    	$.ajax({
                            type: "post",
                            url: ctx + "common/upload",
                    		data: data,
                    		cache: false,
                    		contentType: false,
                    		processData: false,
                    		dataType: 'json',
                    		success: function(result) {
                    		    if (result.code == web_status.SUCCESS) {
                    		        $('#' + obj.id).summernote('insertImage', result.fileName);
                    		    } else {
                    		        $.modal.alertError(result.msg);
                    		    }
                    		},
                    		error: function(error) {
                    		    $.modal.alertWarning("图片上传失败。");
                    		}
                    	});
                    }
                }
            });
        });
    </script>
</body>
</html>